﻿<%@ WebHandler Language="C#" Class="lists" %>
using Models;
using System;
using System.Web;
using Newtonsoft.Json;
using System.Linq;


public class lists : IHttpHandler {

    public void ProcessRequest (HttpContext context) {
   context.Response.ContentType = "text/plain";

        string query = HttpContext.Current.Request.Params["page"];
        string goods_ids = HttpContext.Current.Request.Params["goods_ids"];
            

        if (string.IsNullOrEmpty(query))
        {
            HttpContext.Current.Response.Write("parameter error");
            return;
        }

        var code = 1;
        var msg = "商品列表";
        var time = DateTime.Now;

        using (Entities bll = new Entities())
        {
            var result = bll.S_Goods.Where(p => p.IsLock != true).Select(x => new
            {
                x.GID,
                x.GName,
                x.SCCLASSID,
                x.GImg,
                x.GPriceYJ,
                x.GSales,
                x.GSort

            });//全部.ToList();

           
            var total =result.Count();
            var per_page = 10;
            var current_page=1;
            var last_page=1;
           
            string jsonStr = "{\"total\":\"tom\",\"per_page\":11,\"current_page\":\"tom\",\"last_page\":11,\"data\":"+JsonConvert.SerializeObject(result.ToList()).ToString()+"}";


            var data = new { total,per_page,current_page, last_page,jsonStr};

            context.Response.Write(JsonConvert.SerializeObject(new { code,msg,time,data}));

        }
  
        HttpContext.Current.Response.End();
        //context.Response.Write("Hello World");


    }

    public bool IsReusable {
        get {
            return false;
        }
    }

}